#ifndef STLUTIL_H
#define STLUTIL_H
#include <vector>
#include <string>


namespace tinyscript{
namespace util{

template< typename T >
const T* VectorAsRawArray( const std::vector<T>& buf , size_t sz = 0) {
    const T* f = &(*(buf.begin()));
    return (f+sz);
}

template< typename T >
T* VectorAsRawArray( std::vector<T>& buf , size_t sz = 0 ) {
    const T* f = *(buf.begin());
    return (f+sz);
}

// Not a portable way to hack the string
inline char* StringAsArray( std::string* str , size_t pos = 0) {
	return &((*str)[pos]);
}

template< typename T >
inline std::string FromString( const std::vector<T>& buf , size_t start , size_t end );

template<>
inline std::string FromString<char>( const std::vector<char>& buf , size_t start  , size_t end ) {
	return std::string( VectorAsRawArray(buf,start) , end-start );
}

}
}


#endif // STLUTIL_H
